package com.netease.course;

import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class TestContainer {
	public static void main(String[] args) {
		ApplicationContext context = new ClassPathXmlApplicationContext("application-context.xml");

		Header header = context.getBean("header", CrossHeader.class);
		System.out.println(header.getInfo());
		header.doWork();

		Header header2 = context.getBean("header_map", CrossHeader.class);
		System.out.println(header2.getInfo());
		header2.doWork();

		Header header3 = context.getBean("header_prop", CrossHeader.class);
		System.out.println(header3.getInfo());
		header3.doWork();

		Header header4 = context.getBean("header_file", CrossHeader.class);
		System.out.println(header4.getInfo());
		header4.doWork();

		ScrewDriver screwDriver = context.getBean("screwDriver_autowire", ScrewDriver.class);
		screwDriver.use();

		Header header5 = context.getBean("header_annotation", StraightHeader.class);
		System.out.println(header5.getInfo());
		header5.doWork();

		((ConfigurableApplicationContext) context).close();
	}
}
